home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
text_utl
/
emedit20
/
gotoline.fr_
/
gotoline.fr
Wrap
Text File
|
1995-09-04
|
8KB
|
265 lines
VERSION 2.00
Begin Form frmGotoLine
BorderStyle = 3 'Fixed Double
Caption = "Goto Line"
ClientHeight = 1692
ClientLeft = 216
ClientTop = 2616
ClientWidth = 5112
Height = 2016
Left = 168
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1692
ScaleWidth = 5112
Top = 2340
Width = 5208
Begin CommandButton cmdRemove
Caption = "&Remove"
Height = 312
Left = 4140
TabIndex = 12
Top = 1260
Visible = 0 'False
Width = 852
End
Begin CommandButton cmdAdd
Caption = "&Add"
Height = 312
Left = 4140
TabIndex = 11
Top = 900
Visible = 0 'False
Width = 852
End
Begin Frame Frame1
Caption = "Go To &What"
Height = 1152
Left = 120
TabIndex = 2
Top = 60
Width = 1332
Begin OptionButton optBookmark
Caption = "&Bookmark"
Height = 252
Left = 60
TabIndex = 4
Top = 660
Width = 1212
End
Begin OptionButton optLine
Caption = "&Line"
Height = 192
Left = 60
TabIndex = 3
Top = 360
Value = -1 'True
Width = 1212
End
End
Begin CommandButton cmdcancel
Cancel = -1 'True
Caption = "Cancel"
Height = 312
Left = 4140
TabIndex = 1
Top = 540
Width = 852
End
Begin CommandButton cmdOK
Caption = "&OK"
Default = -1 'True
Height = 312
Left = 4140
TabIndex = 0
Top = 180
Width = 840
End
Begin Frame frameBookmark
Height = 1152
Left = 1560
TabIndex = 8
Top = 60
Width = 2472
Begin ComboBox comboBookmark
Height = 288
Left = 120
Sorted = -1 'True
TabIndex = 10
Text = "comboBookmark"
Top = 540
Width = 2292
End
Begin Label Label2
Caption = "B&ookmark Name"
Height = 252
Left = 120
TabIndex = 9
Top = 240
Width = 1452
End
End
Begin Frame frameLine
Height = 1152
Left = 1560
TabIndex = 5
Top = 60
Width = 2472
Begin TextBox Text1
Height = 288
Left = 180
TabIndex = 7
Top = 480
Width = 1668
End
Begin Label Label1
Caption = "Line &Number:"
Height = 252
Left = 180
TabIndex = 6
Top = 240
Width = 1452
End
End
End
Option Explicit
Sub AddBookmark ()
' If the bookmark already exists then don't do anything
Dim BookmarkName As String
BookmarkName = Trim$(comboBookmark.Text)
Dim BookmarkIndex As Long
For BookmarkIndex = 0 To frmMDI.ActiveForm.Text1.BookmarkCount - 1
If frmMDI.ActiveForm.Text1.BookmarkName(BookmarkIndex) = BookmarkName Then
Exit Sub
End If
Next
'Don't allow blank bookmark names
If BookmarkName = "" Then Exit Sub
'Now add the bookmark
'
'If there are any removed bookmarks then use them
For BookmarkIndex = 0 To frmMDI.ActiveForm.Text1.BookmarkCount - 1
If frmMDI.ActiveForm.Text1.BookmarkOffset(BookmarkIndex) < 0 Then
frmMDI.ActiveForm.Text1.BookmarkName(BookmarkIndex) = BookmarkName
frmMDI.ActiveForm.Text1.BookmarkOffset(BookmarkIndex) = frmMDI.ActiveForm.Text1.CaretOffset
Exit Sub
End If
Next
'
'There are not removed bookmarks so create a new one.
BookmarkIndex = frmMDI.ActiveForm.Text1.BookmarkCount
frmMDI.ActiveForm.Text1.BookmarkCount = frmMDI.ActiveForm.Text1.BookmarkCount + 1
frmMDI.ActiveForm.Text1.BookmarkName(BookmarkIndex) = BookmarkName
frmMDI.ActiveForm.Text1.BookmarkOffset(BookmarkIndex) = frmMDI.ActiveForm.Text1.CaretOffset
End Sub
Sub cmdAdd_Click ()
AddBookmark
End Sub
Sub cmdCancel_Click ()
Me.Hide
End Sub
Sub cmdOK_Click ()
DoIt
Me.Hide
End Sub
Sub cmdRemove_Click ()
RemoveBookmark
End Sub
Sub DoIt ()
On Error GoTo SearchError
' go to a line
If optLine.Value <> 0 Then
'Parse the users text into a long variable.
'On error jump to SearchError
Dim GoDestination As Long
GoDestination = CLng(Text1.Text)
Resume Next
frmMDI.ActiveForm.Text1.CaretY = CLng(Text1.Text)
' go to a bookmark
Else
Dim BookmarkName As String
BookmarkName = Trim$(comboBookmark.Text)
Dim MarkIndex As Long
For MarkIndex = 0 To frmMDI.ActiveForm.Text1.BookmarkCount - 1
If frmMDI.ActiveForm.Text1.BookmarkName(MarkIndex) = BookmarkName Then
frmMDI.ActiveForm.Text1.CaretOffset = frmMDI.ActiveForm.Text1.BookmarkOffset(MarkIndex)
Exit For
End If
Next
End If
SearchError:
Resume Next
End Sub
Sub FillBookmarkList ()
Dim i As Long
comboBookmark.Clear
For i = 0 To frmMDI.ActiveForm.Text1.BookmarkCount - 1
If 0 <= frmMDI.ActiveForm.Text1.BookmarkOffset(i) Then
comboBookmark.AddItem frmMDI.ActiveForm.Text1.BookmarkName(i)
End If
Next
If 0 < comboBookmark.ListCount Then
comboBookmark.ListIndex = 0
Else
comboBookmark.ListIndex = -1
End If
End Sub
Sub Form_Activate ()
CenterFormInApp Me
FillBookmarkList
End Sub
Sub Form_Load ()
frameLine.ZOrder
End Sub
Sub optBookmark_Click ()
cmdRemove.Visible = True
frameBookmark.ZOrder
cmdAdd.Visible = True
End Sub
Sub optLine_Click ()
cmdRemove.Visible = False
cmdAdd.Visible = False
frameLine.ZOrder
End Sub
Sub RemoveBookmark ()
' If the bookmark doesn't exist then don't do anything
Dim BookmarkName As String
BookmarkName = Trim$(comboBookmark.Text)
Dim BookmarkIndex As Long
For BookmarkIndex = 0 To frmMDI.ActiveForm.Text1.BookmarkCount - 1
If frmMDI.ActiveForm.Text1.BookmarkName(BookmarkIndex) = BookmarkName Then
GoTo BookmarkExists:
End If
Next
Exit Sub
BookmarkExists:
'Now remove the bookmark
If BookmarkIndex = frmMDI.ActiveForm.Text1.BookmarkCount - 1 Then
frmMDI.ActiveForm.Text1.BookmarkCount = frmMDI.ActiveForm.Text1.BookmarkCount - 1
Else
frmMDI.ActiveForm.Text1.BookmarkName(BookmarkIndex) = "Removed"
frmMDI.ActiveForm.Text1.BookmarkOffset(BookmarkIndex) = -1
End If
FillBookmarkList
End Sub